package com.ycu.jk16.mall.dao;

import static com.ycu.jk16.mall.util.common.AndroidMalConstant.PRODUCT_PHOTO_TABLE;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import com.ycu.jk16.mall.dao.provider.ProductPhotoDynaSqlProvider;
import com.ycu.jk16.mall.domain.ProductPhoto;

public interface ProductPhotoDao {
	@Select("select * from " + PRODUCT_PHOTO_TABLE + " where product_id = #{id}")
	@Results({ // 将JavaBean里的变量名与数据库字段名不相符的进行标注
		@Result(column = "product_id", property = "id", id = true),
		@Result(column = "subimage", property = "subImage", javaType = String.class) })
	List<ProductPhoto> selectById(@Param("id")Integer id);
	
	// 动态插入产品辅图
			@SelectProvider(type = ProductPhotoDynaSqlProvider.class, method = "insertProductPhoto")
			void insertProductPhoto(ProductPhoto productPhoto);
			
			@Select("delete from " + PRODUCT_PHOTO_TABLE + " where product_id = #{id}")
			void deleteProductPhotoById(@Param("id")Integer id);
}
